package graphics.screens;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import tool.ImageUtils;
import boot.Boot;
import function.Mp3File;
import graphics.BootColor;

public class DeleteNewScreen extends Canvas implements CommandListener {

	private final Command okCommand = new Command("OK", Command.OK, 1);
	private final Command cancelCommand = new Command("Cancel", Command.EXIT, 1);
	private Mp3File mp3;

	public DeleteNewScreen(Mp3File aMp3) {
		mp3 = aMp3;
		setup();
	}

	public void setup() {
		addCommand(okCommand);
		addCommand(cancelCommand);
		setCommandListener(this);
	}

	protected void paint(Graphics graphics) {
		graphics.setColor(BootColor.BLACK);
		graphics.fillRect(0, 0, 240, 250);

		drawSplash(graphics);

		graphics.setColor(BootColor.FLASHY_MENU_COLOR);
		graphics.drawString("Delete tune", 120,
				(graphics.getFont().getHeight()), Graphics.TOP
						| Graphics.HCENTER);
		graphics.setColor(BootColor.WHITE);
		graphics.drawString(mp3.getTitle(), 120, (graphics.getFont()
				.getHeight() * 2), Graphics.TOP | Graphics.HCENTER);
	}

	private void drawSplash(Graphics graphics) {
		Image splash = ImageUtils.getImageFromImageFolder("/Musique-mini.png");
		graphics.drawImage(splash, 0, 0, Graphics.LEFT | Graphics.TOP);
	}

	public void commandAction(Command command, Displayable disp) {

		if (command == okCommand) {
			Boot.getInstance().deleteCurrentMp3();
		} else if (command == cancelCommand) {
			Boot.getInstance().readyToGo();
		}
	}

}
